<template>
    <div>
        <el-select v-model="platform" filterable clearable :size="size" @change="onChange">
            <el-option v-for="(item, index) in platformList" :key="index" :label="item.name" :value="item.id"></el-option>
        </el-select>
    </div>
</template>
<script>
export default {
    name: "PlatformSelect",
    props: {
        value: {
            type: [String, Number],
            default: "",
        },
        size: {
            type: String,
            default: ''
        },
        multiple: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {
            platformList: [
                { name: '小程序', id: '小程序' },
                { name: 'PC', id: 'PC' },
                { name: 'H5', id: 'H5' },
            ],
            platform: '',
        };
    },
    watch: {
        value: {
            handler: function (n, o) {
                if (!n) {
                    this.platform = '';
                }
                this.platform = n;
            },
            immediate: true,
        },
    },
    created() {

    },
    methods: {
        // 监听组件变化
        onChange(e) {
            console.log(e);
            this.$emit("input", e);
            this.$emit("change", e);
        },
    },
};
</script>
<style lang="scss" scoped>

</style>